
//
// 120325 - AH - (Garage *) Created.
// 120727 - AH - (Midtun *) Responds with array not list as used to.
//

package org.soekrat.server.servlets.ce;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.soekrat.server.io.db.ConversationElement;
import org.soekrat.server.io.db.SoekratDAO;
import org.soekrat.server.io.db.SoekratDAOFactory;
import org.soekrat.server.servlets.AbstractSoekratHttpServlet;

/**
 * <p>
 *   Implements request to get all 
 *   {@link ConversationElement} keys.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
@SuppressWarnings("serial")
public final class GetConversationElementKeysHttpServlet 
  extends AbstractSoekratHttpServlet 
{
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public GetConversationElementKeysHttpServlet(){}

  @Override
  protected void handleRequest(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException 
  {
    SoekratDAO dao=new SoekratDAOFactory().create();
    
    List<Long> keys=dao.getConversationElementKeys();
    
    respond(res, keys.toArray(LONG_E_ARRAY));
  }
  
  private final static Long[] LONG_E_ARRAY=new Long[0];
  
}
